<extend name="Public/base" />
<block name="content">
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a href="{:U('Index/index')}" title="首页" class="tip-bottom"><i class="icon-home"></i> 首页</a> 
			<a href="#" class="current">{$meta_title}</a>
		</div>
	</div>
	<div class="container-fluid">
		<br/>
		<div class="search-form fl cf span12">
			<form autocomplete="off">
				<div class="sleft">
					{:R('ServiceStatistics/getHouseInfo')}
					<hr>
					<div class="control" id="demand_list" style="margin:20px 0 5px 0;"></div>
					<hr>
					<div class="control" id="member_list" style="margin:20px 0 5px 0;"></div>
					<hr>
				</div>
				<button class="btn btn-primary" type="button" onclick="$('form').submit()" id="search_count">确认筛选</button>　<img id="loading" style="display:none;" src="__IMG__/loading.gif">
			</form>
		</div>
		
		<div class="row-fluid">
			<div class="span12">
				<div class="widget-box">
					<div class="widget-content ">
						<center id="count_content" style="display:none;"></center>
						<center id="null_table">暂无数据</center>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
$(function (){
	//select2
	$('select').select2();
	//需求加载
	$.ajax({ url: "{:U('ServiceStatistics/getDemandList')}", success: function(data){
		if('' != data){
        	$('#demand_list').html(data).hide().fadeIn(500);
		}
        //员工加载
        $.ajax({ url: "{:U('ServiceStatistics/getMemberList')}", success: function(data){
        	if('' != data){
            	$('#member_list').html(data).hide().fadeIn(300);
        	}
            //初始化控件
            var IS_INIT = 1;
         	// 全选
            $(".checkbox-all").bind("click",function(){
                $(this).nextAll("div.checkbox-group").children("label").children("input").prop("checked", true);
            });
            // 反选
            $(".checkbox-opposite").bind("click",function(){
                $(this).nextAll("div.checkbox-group").children("label").children("input[type=checkbox]").each(function(e) {
                    if ($(this).is(":checked")) {
                        $(this).prop("checked", false);
                    }else{
                        $(this).prop("checked", true);
                    }
                });
            });
    	}});
	}});
	//统计
	$('form').submit(function(){
		$('#search_count').prop('disabled', true);
		$('#loading').show();
		$.post("{:U('ServiceStatistics/customer')}", $('form').serialize(), call_back, "json");
		return false;
		function call_back(data){
			if(data.status == 1){
				var html_str = '在选择条件下共有客户：' + data.info;
				$('#null_table').hide();
				$('#count_content').html(html_str).fadeIn(300);;
			}else{
				tke_alert(data.info, 'alert-error', 2000);
				$('#null_table').show();
				$('#count_content').hide();
				$('#count_content').html('');
			}
			setTimeout(function(){
				$('#loading').hide();
				$('#search_count').prop('disabled', false);
			}, 1000);
		}
	});
	//日期控件
	$(".datepicker").datetimepicker({
		format: 'yyyy-mm-dd',
		minView: 'month',
	    autoclose: true,
	    todayBtn: true
	});
});
//导航高亮
highlight_subnav("{:U('ServiceStatistics/customer')}");
</script>
</block>